﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThuatToanDAO;
using System.Data.SqlClient;
using System.Data;
using ThuatToan.Utils;


public partial class _Default : System.Web.UI.Page
{
    //For Paging
    /*
    public int currentPage = 0;
    // so item trong tung trang
    public int numberByPage;
    // so trang 
    public int numberOfPage = 0;
    public int pageid;

    public String thuattoan = ""; */

    protected void Page_Load(object sender, EventArgs e)
    {
        //For Paging
        /*
        numberByPage = Constant.NUMBERPAGE;
        if (!string.IsNullOrEmpty(Request.Params["pageid"]))
        {
            int.TryParse(Request.Params["pageid"], out currentPage);
        }
        else
        {
            currentPage = 1;
        }

        if (!IsPostBack)
        {
            int workCount = 0;
            ItemDAO item = new ItemDAO();

            List<SqlParameter> listparam = new List<SqlParameter>();

            listparam.Add(new SqlParameter("Name", txtInput.Text));

            DataSet ds = item.ExecuteSelectTotalItem(listparam);
            
            int.TryParse(ds.Tables[0].Rows[0]["Count"].ToString(), out workCount) ;

            numberOfPage = (int)Math.Ceiling((decimal)workCount / numberByPage);
            pageid = currentPage - 1;

        }
         
        */
            
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {

        //For Paging
        //thuattoan = txtInput.Text;
        //Response.Redirect("~/Default.aspx?thuattoan=" + thuattoan);

        lbl_Norecord.Visible = false;

        ItemDAO item = new ItemDAO();

        List<SqlParameter> listparam = new List<SqlParameter>();

        listparam.Add(new SqlParameter("Name", txtInput.Text));
        listparam.Add(new SqlParameter("CategoryID", -1));


        DataSet ds = item.ExecuteSearch(listparam);

        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();

        if (ds.Tables[0].Rows.Count == 0)
        {
            lbl_Norecord.Visible = true;
        }

        
    }
}